#pragma once

#include "resource.h"

const int ID_T2 = 1001;

struct MouseEventArgs {
	HWND hwnd;
	int x;
	int y;
	UINT keyFlags;
};

struct Point {
	float x;
	float y;

	Point(const float& x = 0.0f, const float& y = 0.0f);
	Point(const Point& point);
};

struct Wall {
	Point start;
	Point end;
	float thickness;

	Point startr;
	Point endr;

	Wall(const Point& start, const Point& end, float thickness);
};

struct T2 {
	HWND hwnd;

	// mhistory: history of recent mouse event arguments
	std::vector<MouseEventArgs> mhistory;
	std::vector<Wall> walls;
};

ATOM Main_RegisterClass(HINSTANCE hInstance);
ATOM T2_RegisterClass(HINSTANCE hInstance);

LRESULT CALLBACK Main_WndProc(HWND hwnd, UINT message,
							  WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK T2_WndProc(HWND hwnd, UINT message,
							  WPARAM wParam, LPARAM lParam);

void Main_OnSize(HWND hwnd, UINT state, int cx, int cy);
void Main_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify);
void Main_OnDestroy(HWND hwnd);

BOOL T2_OnCreate(HWND hwnd, LPCREATESTRUCT lpCreateStruct);

void DrawWall(HDC hdc, Wall& wall);
void Render(HDC hdc, HWND hwnd, T2 *t2);
void T2_OnPaint(HWND hwnd);
void T2_OnLButtonUp(HWND hwnd, int x, int y, UINT keyFlags);
void T2_OnMouseMove(HWND hwnd, int x, int y, UINT keyFlags);
void T2_OnDestroy(HWND hwnd);